<%@ page contentType="text/html;charset=UTF-8" language="java"%>

<html:js  name="peity,iCheck,sweetalert,datepicker,Validform"/>
<!-- 自定义js -->
<script src="${staticPath}/common/js/content.js?v=1.0.0"></script>

<script type="text/javascript">
        //初始化表单
		var validateForm;
		var callFunc;
		var loadIndex = null;
		//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
		function doSubmit(func){
			callFunc=func;
		    validateForm.ajaxPost();
		}
		$(document).ready(function() {
		        validateForm = $("#<sitemesh:getProperty property='body.formid'/>").Validform({
		        ajaxPost:true,
				tiptype:function(msg,o,cssctl){
					if(!o.obj.is("form")){
						var objtip=o.obj.siblings(".Validform_checktip");
						cssctl(objtip,o.type);
						objtip.text(msg);
					}
				},beforeSubmit:function(curform){
					loadIndex = openLoad();
					try{
						var beforeFunc=<sitemesh:getProperty property='body.beforeSubmit' default='beforeSubmit'/>;
						if(beforeFunc&&typeof(beforeFunc)=="function"){
							var flag = beforeFunc(curform); 
							if(!flag){
								closeLoad(loadIndex);
							}
							return flag; 
						}
					}catch(err){
						
					}
					return true;	
				},callback:function(result){
					 closeLoad(loadIndex);
					 callFunc(result);
				}
			});
		});
		
		/**
		 * @description 打开layer的加载层.<br>
		 * @returns 返回打开的阴影层的下标.<br>
		 * @author zcg.<br>
		 */
		function openLoad(){
			return top.layer.load(2, {
				shade: [0.3,'#fff'],
				shadeClose : false
			});
		}

		/**
		 * @description 关闭layer的加载层.<br>
		 * @returns 返回打开的阴影层的下标.<br>
		 * @author zcg.<br>
		 */
		function closeLoad(index){
			top.layer.close(index);
		}
</script>